home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / CodeFragments.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  8.5 KB  |  302 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        CodeFragments.h
  3.  
  4.      Contains:    Code Fragment Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CODEFRAGMENTS__
  21. #define __CODEFRAGMENTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __FILES__
  30. #include <Files.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <OSUtils.h>                                        */
  34. /*        #include <Memory.h>                                        */
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_ALIGN_SUPPORTED
  41. #pragma options align=mac68k
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48.  
  49. enum {
  50.     kCFragResourceType            = 'cfrg',
  51.     kCFragResourceID            = 0,
  52.     kCFragLibraryFileType        = 'shlb'
  53. };
  54.  
  55. typedef OSType CFragArchitecture;
  56.  
  57.  
  58. enum {
  59.     kPowerPCCFragArch            = 'pwpc',
  60.     kMotorola68KCFragArch        = 'm68k',
  61.     kAnyCFragArch                = 0x3F3F3F3F
  62. };
  63.  
  64. #if GENERATINGPOWERPC
  65. enum {
  66.     kCurrentCFragArch            = kPowerPCCFragArch
  67. };
  68.  
  69. #endif
  70. #if GENERATING68K    
  71. enum {
  72.     kCurrentCFragArch            = kMotorola68KCFragArch
  73. };
  74.  
  75. #endif
  76. typedef UInt32 CFragConnectionID;
  77.  
  78. typedef UInt32 CFragClosureID;
  79.  
  80. typedef UInt32 CFragContextID;
  81.  
  82. typedef UInt32 CFragContainerID;
  83.  
  84. typedef UInt32 CFragLoadOptions;
  85.  
  86.  
  87. enum {
  88.     kLoadCFrag                    = 0x01,                            /* Try to use existing copy, load if not found.*/
  89.     kFindCFrag                    = 0x02,                            /* Try find an existing copy, don't load if not found.*/
  90.     kNewCFragCopy                = 0x05,                            /* Load a new copy whether one already exists or not.*/
  91.     kInplaceCFrag                = 0x80                            /* Use data sections directly in the container.*/
  92. };
  93.  
  94. enum {
  95.     kUnresolvedCFragSymbolAddress = 0
  96. };
  97.  
  98. typedef UInt8 CFragSymbolClass;
  99.  
  100.  
  101. enum {
  102.     kCodeCFragSymbol            = 0,
  103.     kDataCFragSymbol            = 1,
  104.     kTVectorCFragSymbol            = 2,
  105.     kTOCCFragSymbol                = 3,
  106.     kGlueCFragSymbol            = 4
  107. };
  108.  
  109. typedef UInt8 CFragUsage;
  110.  
  111.  
  112. enum {
  113.     kImportLibraryCFrag            = 0,                            /* Standard CFM import library.*/
  114.     kApplicationCFrag            = 1,                            /* Macintosh application.*/
  115.     kDropInAdditionCFrag        = 2                                /* Private extension to an application or library.*/
  116. };
  117.  
  118. enum {
  119.     kIsCompleteCFrag            = 0,                            /* A "base" fragment, not an update.*/
  120.     kFirstCFragUpdate            = 1                                /* The first update, others are numbered 2, 3, ...*/
  121. };
  122.  
  123. typedef UInt8 CFragLocatorKind;
  124.  
  125.  
  126. enum {
  127.     kMemoryCFragLocator            = 0,                            /* Container is already addressable.*/
  128.     kDataForkCFragLocator        = 1,                            /* Container is in a file's data fork.*/
  129.     kResourceCFragLocator        = 2,                            /* Container is in a file's resource fork.*/
  130.     kByteStreamCFragLocator        = 3                                /* Container is in a given file fork as a byte stream.*/
  131. };
  132.  
  133. #define IsFileLocation(where)     \
  134.     ( ((where) == kDataForkCFragLocator)    ||  \
  135.     ((where) == kResourceCFragLocator)    ||  \
  136.     ((where) == kByteStreamCFragLocator) )
  137. enum {
  138.     kCFragGoesToEOF                = 0
  139. };
  140.  
  141. struct CFragOldMemoryLocator {
  142.     LogicalAddress                    address;
  143.     UInt32                            length;
  144.     Boolean                            inPlace;
  145.     UInt8                            reserved3a[3];                /* ! Do not use this!*/
  146. };
  147.  
  148. typedef struct CFragOldMemoryLocator CFragOldMemoryLocator;
  149.  
  150. struct CFragHFSDiskFlatLocator {
  151.     FSSpecPtr                        fileSpec;
  152.     UInt32                            offset;
  153.     UInt32                            length;
  154. };
  155. typedef struct CFragHFSDiskFlatLocator CFragHFSDiskFlatLocator;
  156.  
  157. /* ! This must have a file specification at the same offset as a data fork locator!*/
  158. struct CFragHFSSegmentedLocator {
  159.     FSSpecPtr                        fileSpec;
  160.     OSType                            rsrcType;
  161.     SInt16                            rsrcID;
  162.     UInt16                            reserved2a;                    /* ! Do not use this!*/
  163. };
  164.  
  165. typedef struct CFragHFSSegmentedLocator CFragHFSSegmentedLocator;
  166.  
  167. struct CFragHFSLocator {
  168.     SInt32                            where;                        /* Really of type CFragLocatorKind.*/
  169.     union {
  170.         CFragHFSDiskFlatLocator            onDisk;                    /* First so debugger shows this form.*/
  171.         CFragOldMemoryLocator            inMem;
  172.         CFragHFSSegmentedLocator        inSegs;
  173.     } u;
  174. };
  175.  
  176. typedef struct CFragHFSLocator CFragHFSLocator;
  177.  
  178. typedef CFragHFSLocator *CFragHFSLocatorPtr;
  179.  
  180. /* -------------------------------------------------------------------------------------------*/
  181. /* The parameter block passed to fragment initialization functions.  The locator and name*/
  182. /* pointers are valid only for the duration of the initialization routine.  I.e. if you want*/
  183. /* to save the locator or name, save the contents, not the pointers.  Initialization routines*/
  184. /* take one parameter, a pointer to the parameter block, and return a success/failure result.*/
  185. /* ! Note that the initialization function returns an OSErr.  Any result other than noErr will*/
  186. /* ! cause the entire load to be aborted at that point.*/
  187. struct CFragInitBlock {
  188.     CFragContextID                    contextID;
  189.     CFragClosureID                    closureID;
  190.     CFragConnectionID                connectionID;
  191.     CFragHFSLocator                    fragLocator;
  192.     StringPtr                        libName;
  193.     UInt32                            reserved4a;                    /* ! Do not use this!*/
  194.     UInt32                            reserved4b;                    /* ! Do not use this!*/
  195.     UInt32                            reserved4c;                    /* ! Do not use this!*/
  196.     UInt32                            reserved4d;                    /* ! Do not use this!*/
  197. };
  198. typedef struct CFragInitBlock CFragInitBlock;
  199.  
  200. typedef CFragInitBlock *CFragInitBlockPtr;
  201.  
  202. typedef pascal OSErr CFragInitFunction(const CFragInitBlock *theInitBlock);
  203. typedef pascal void CFragTermRoutine(void);
  204. typedef CFragInitFunction *CFragInitFunctionPtr;
  205.  
  206. typedef CFragTermRoutine *CFragTermRoutinePtr;
  207.  
  208. /* §*/
  209. /* ===========================================================================================*/
  210. /* Routines*/
  211. /* ========*/
  212. extern pascal OSErr GetSharedLibrary(ConstStr63Param libName, OSType archType, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  213.  THREEWORDINLINE(0x3F3C, 0x0001, 0xAA5A);
  214. extern pascal OSErr GetDiskFragment(const FSSpec *fileSpec, UInt32 offset, UInt32 length, ConstStr63Param fragName, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  215.  THREEWORDINLINE(0x3F3C, 0x0002, 0xAA5A);
  216. extern pascal OSErr GetMemFragment(void *memAddr, UInt32 length, ConstStr63Param fragName, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  217.  THREEWORDINLINE(0x3F3C, 0x0003, 0xAA5A);
  218. extern pascal OSErr CloseConnection(CFragConnectionID *connID)
  219.  THREEWORDINLINE(0x3F3C, 0x0004, 0xAA5A);
  220. extern pascal OSErr FindSymbol(CFragConnectionID connID, ConstStr255Param symName, Ptr *symAddr, CFragSymbolClass *symClass)
  221.  THREEWORDINLINE(0x3F3C, 0x0005, 0xAA5A);
  222. extern pascal OSErr CountSymbols(CFragConnectionID connID, long *symCount)
  223.  THREEWORDINLINE(0x3F3C, 0x0006, 0xAA5A);
  224. extern pascal OSErr GetIndSymbol(CFragConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, CFragSymbolClass *symClass)
  225.  THREEWORDINLINE(0x3F3C, 0x0007, 0xAA5A);
  226. #if OLDROUTINENAMES
  227. typedef CFragConnectionID ConnectionID;
  228.  
  229. typedef CFragLoadOptions LoadFlags;
  230.  
  231. typedef CFragSymbolClass SymClass;
  232.  
  233. typedef CFragOldMemoryLocator MemFragment;
  234.  
  235. typedef CFragHFSDiskFlatLocator DiskFragment;
  236.  
  237. typedef CFragHFSSegmentedLocator SegmentedFragment;
  238.  
  239. typedef CFragHFSLocator FragmentLocator;
  240.  
  241. typedef CFragHFSLocatorPtr FragmentLocatorPtr;
  242.  
  243. typedef CFragInitBlock InitBlock;
  244.  
  245. typedef CFragInitBlockPtr InitBlockPtr;
  246.  
  247. typedef CFragInitFunction ConnectionInitializationRoutine;
  248.  
  249. typedef CFragTermRoutine ConnectionTerminationRoutine;
  250.  
  251.  
  252. enum {
  253.     kPowerPCArch                = kPowerPCCFragArch,
  254.     kMotorola68KArch            = kMotorola68KCFragArch,
  255.     kAnyArchType                = kAnyCFragArch,
  256.     kNoLibName                    = 0,
  257.     kNoConnectionID                = 0,
  258.     kLoadLib                    = kLoadCFrag,
  259.     kFindLib                    = kFindCFrag,
  260.     kLoadNewCopy                = kNewCFragCopy,
  261.     kUseInPlace                    = kInplaceCFrag,
  262.     kCodeSym                    = kCodeCFragSymbol,
  263.     kDataSym                    = kDataCFragSymbol,
  264.     kTVectSym                    = kTVectorCFragSymbol,
  265.     kTOCSym                        = kTOCCFragSymbol,
  266.     kGlueSym                    = kGlueCFragSymbol,
  267.     kInMem                        = kMemoryCFragLocator,
  268.     kOnDiskFlat                    = kDataForkCFragLocator,
  269.     kOnDiskSegmented            = kResourceCFragLocator,
  270.     kIsLib                        = kImportLibraryCFrag,
  271.     kIsApp                        = kApplicationCFrag,
  272.     kIsDropIn                    = kDropInAdditionCFrag,
  273.     kFullLib                    = kIsCompleteCFrag,
  274.     kUpdateLib                    = kFirstCFragUpdate,
  275.     kWholeFork                    = kCFragGoesToEOF,
  276.     kCFMRsrcType                = kCFragResourceType,
  277.     kCFMRsrcID                    = kCFragResourceID,
  278.     kSHLBFileType                = kCFragLibraryFileType,
  279.     kUnresolvedSymbolAddress    = kUnresolvedCFragSymbolAddress
  280. };
  281.  
  282. enum {
  283.     kPowerPC                    = kPowerPCCFragArch,
  284.     kMotorola68K                = kMotorola68KCFragArch
  285. };
  286.  
  287. #endif
  288.  
  289. #if PRAGMA_IMPORT_SUPPORTED
  290. #pragma import off
  291. #endif
  292.  
  293. #if PRAGMA_ALIGN_SUPPORTED
  294. #pragma options align=reset
  295. #endif
  296.  
  297. #ifdef __cplusplus
  298. }
  299. #endif
  300.  
  301. #endif /* __CODEFRAGMENTS__ */
  302.